Skip to content

Conversation

@minggangw
Copy link
Member

@minggangw minggangw commented Apr 22, 2025

This PR splits the large rcl_bindings.cpp file into several smaller, dedicated binding files to improve modularity and maintainability. Key changes include the addition of new files (e.g. rcl_node_bindings.cpp, rcl_names_bindings.cpp, rcl_logging_bindings.cpp, etc.), updates to the addon.cpp and binding.gyp files to reference these new modules, and renaming of certain initialization functions for consistency.

Meanwhile, this patch fixes the GitHub actions failure for Linux platform.

Fix: #1099

@minggangw minggangw requested a review from Copilot April 22, 2025 07:00
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR splits the large rcl_bindings.cpp file into several smaller, dedicated binding files to improve modularity and maintainability. Key changes include the addition of new files (e.g. rcl_node_bindings.cpp, rcl_names_bindings.cpp, rcl_logging_bindings.cpp, etc.), updates to the addon.cpp and binding.gyp files to reference these new modules, and renaming of certain initialization functions for consistency.

Reviewed Changes

Copilot reviewed 35 out of 35 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/rcl_node_bindings.cpp New binding functions for node operations; extracts parameter wrapping.
src/rcl_names_bindings.{h,cpp} New bindings to support name validations and expansions.
src/rcl_logging_bindings.{h,cpp} New logging bindings for setting logger level and log messages.
src/rcl_lifecycle_bindings.{h,cpp} Renamed lifecycle initializer to InitLifecycleBindings for consistency.
src/rcl_context_bindings.cpp New context bindings with argv allocation; potential allocation issue.
addon.cpp Updated to initialize new binding modules.
binding.gyp Updated file list to include the new binding files.

for (int i = 0; i < argc; i++) {
std::string arg = jsArgv.Get(i).As<Napi::String>().Utf8Value();
int len = arg.length() + 1;
argv[i] = reinterpret_cast<char*>(malloc(len * sizeof(char*)));
Copy link

Copilot AI Apr 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The allocation for argv[i] uses sizeof(char*) instead of sizeof(char), which may allocate an incorrect amount of memory. Replace sizeof(char*) with sizeof(char) for proper allocation.

Suggested change
argv[i] = reinterpret_cast<char*>(malloc(len * sizeof(char*)));
argv[i] = reinterpret_cast<char*>(malloc(len * sizeof(char)));

Copilot uses AI. Check for mistakes.
@minggangw minggangw requested a review from Copilot April 22, 2025 09:47
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR splits the original monolithic rcl_bindings.cpp file into multiple dedicated binding files for different ROS components (node, names, logging, lifecycle, graph, context, client, etc.) and updates the build configuration accordingly.

  • Separation of binding code into multiple files for improved modularity and maintainability
  • Renaming and updating of several initialization functions (e.g. InitLifecycleBindings, InitActionBindings)
  • Updating the binding.gyp to include the new source files

Reviewed Changes

Copilot reviewed 34 out of 34 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/rcl_node_bindings.cpp Added bindings for node-related functionality
src/rcl_names_bindings.h/.cpp Introduced new bindings for name-related utilities
src/rcl_logging_bindings.h/.cpp Added logging bindings with functions to set and get logger levels
src/rcl_lifecycle_bindings.{h,cpp} Renamed and updated lifecycle bindings to InitLifecycleBindings
src/rcl_guard_condition_bindings.{h,cpp} New guard condition bindings
src/rcl_graph_bindings.{h,cpp} New graph bindings for publisher/subscriber/service information
src/rcl_context_bindings.{h,cpp} Context initialization and shutdown bindings
src/rcl_client_bindings.{h,cpp} New bindings to support client creation and request management
src/rcl_bindings.h Removed deprecated declarations now managed in separate files
src/rcl_action_bindings.{h,cpp} Renamed action binding functions to InitActionBindings
src/addon.cpp Updated module initialization to load the new binding modules
binding.gyp Added new source files for all the separated binding modules

rcl_get_subscriber_names_and_types_by_node(
node, &allocator, no_demangle, node_name.c_str(),
node_namespace.c_str(), &topic_names_and_types),
"Failed to get_publisher_names_and_types.");
Copy link

Copilot AI Apr 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In GetSubscriptionNamesAndTypesByNode, the error message incorrectly refers to 'publisher' instead of 'subscriber'. Consider updating the error string to 'Failed to get_subscriber_names_and_types.'

Suggested change
"Failed to get_publisher_names_and_types.");
"Failed to get_subscriber_names_and_types.");

Copilot uses AI. Check for mistakes.
rcl_get_subscriber_names_and_types_by_node(
node, &allocator, no_demangle, node_name.c_str(),
node_namespace.c_str(), &topic_names_and_types),
"Failed to get_publisher_names_and_types.");
Copy link

Copilot AI Apr 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In GetServiceNamesAndTypesByNode, the error message erroneously references 'publisher' instead of 'service'. It should likely read 'Failed to get_service_names_and_types.'

Suggested change
"Failed to get_publisher_names_and_types.");
"Failed to get_subscriber_names_and_types.");

Copilot uses AI. Check for mistakes.
RCL_RET_OK,
rcl_get_topic_names_and_types(node, &allocator, no_demangle,
&topic_names_and_types),
"Failed to get_publisher_names_and_types.");
Copy link

Copilot AI Apr 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In GetTopicNamesAndTypes, the error message incorrectly mentions 'publisher' instead of 'topic'. Updating the message to 'Failed to get_topic_names_and_types.' would improve clarity.

Suggested change
"Failed to get_publisher_names_and_types.");
"Failed to get_topic_names_and_types.");

Copilot uses AI. Check for mistakes.
@minggangw minggangw merged commit 88d15f4 into RobotWebTools:develop Apr 23, 2025
5 of 6 checks passed
minggangw added a commit that referenced this pull request Apr 23, 2025
This PR splits the large rcl_bindings.cpp file into several smaller, dedicated binding files to improve modularity and maintainability. Key changes include the addition of new files (e.g. rcl_node_bindings.cpp, rcl_names_bindings.cpp, rcl_logging_bindings.cpp, etc.), updates to the addon.cpp and `binding.gyp` files to reference these new modules, and renaming of certain initialization functions for consistency.

Meanwhile, this patch fixes the GitHub actions failure for Linux platform.

Fix: #1099
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Split rcl_bindings.cpp into small ones

1 participant